pushd `dirname $0`
cd ..
rm -rf ssh/hostident
rm -rf ssh/generated ignition/ssh/generated.pub
ssh-keygen -f ssh/generated -P ""
nix --experimental-features 'nix-command flakes' build --cores 1 --show-trace .#packages.x86_64-linux.qcow2
cp result/nixos.qcow2 ./nixos.qcow2
chmod 0777 nixos.qcow2
rm result

echo "[theserver]"                                              > scripts/rclone.conf
echo "type = sftp"                                             >> scripts/rclone.conf
echo "host = localhost"                                        >> scripts/rclone.conf
echo "user = root"                                             >> scripts/rclone.conf
echo "key_pem = "$(awk '{printf "%s\\n", $0}' < ssh/generated) >> scripts/rclone.conf

popd
